13. Code: DFS
Depth First Search Intro
Tree 101 DFS Intro
Code Along with the Videos
Please open the notebook in a separate tab and follow along with the videos below. To open the notebook in a separate tab, right-click on the "jupyter" icon in the top left corner of the notebook and choose "open link in new tab."
Workspace
This section contains either a workspace (it can be a Jupyter Notebook workspace or an online code editor work space, etc.) and it cannot be automatically downloaded to be generated here. Please access the classroom with your account and manually download the workspace to your local machine. Note that for some courses, Udacity upload the workspace files onto https://github.com/udacity, so you may be able to download them there.
Workspace Information:
- Default file path:
- Workspace type: jupyter
- Opened files (when workspace is loaded): n/a
Tree Setup
Tree 102 DFS Tree Setup
DFS uses a Stack
Tree 103 DFS Stack
Coding Step by Step
Tree 104 DFS Code Without A Loop
DFS implementation with a Bug
Let's look at a common error, an infinite loop, and explain why this is happening.
Tree 105 DFS Pre Order With Infinite Loop
Tracking Additional Information in the Stack
Tree 106 DFS Track State
Code that tracks the State in the Stack
Tree 107 DFS Track State Code
Pre-Order DFS with Recursion Code Intro
Tree 108 DFS Recursion Pre Order Intro
DFS Pre-Order with Recursion Solution
Tree 109 DFS Recursion Pre Order Solution
In-Order and Post-Order Code Intro
Tree 110 DFS Recursion In Order Post Order Intro
In-Order and Post-Order Solution
Tree 111 DFS Recursion In Order Post Order Solution